package com.winshare.saleAssistant.controller;


import com.winshare.saleAssistant.domain.dto.req.PageQueryDTO;
import com.winshare.saleAssistant.model.SaleImportLog;
import com.winshare.saleAssistant.service.ISaleImportLogService;
import com.winshare.saleAssistant.util.LogicResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2020-11-11 18:30:01
 */
@Controller
@RequestMapping("/sys/saleImportLog")
public class SaleImportLogController {


    @Autowired
    private ISaleImportLogService saleImportLogService;


    /**
     * 获取列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestBody PageQueryDTO pageQueryDTO) {
        return LogicResponse.success(saleImportLogService.getSaleImportLog(pageQueryDTO));
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(SaleImportLog saleImportLog) {
        saleImportLogService.save(saleImportLog);
        return LogicResponse.success("success");
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer saleImportLogId) {
        saleImportLogService.removeById(saleImportLogId);
        return LogicResponse.success("success");
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(SaleImportLog saleImportLog) {
        saleImportLogService.updateById(saleImportLog);
        return LogicResponse.success("success");
    }

    /**
     * 详情
     */
    @RequestMapping(value = "/detail/{saleImportLogId}")
    @ResponseBody
    public Object detail(@PathVariable("saleImportLogId") Integer saleImportLogId) {
        return saleImportLogService.getById(saleImportLogId);
    }
}
